home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Atlanta_1990 / Atlanta-Devcon.1 / Libraries / Commodities / MBA / mba.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  2.3 KB  |  85 lines

  1.  
  2.    /***********************************************************************
  3.    *                                                                      *
  4.    *                            COPYRIGHTS                                *
  5.    *                                                                      *
  6.    *   Copyright (c) 1990  Commodore-Amiga, Inc.  All Rights Reserved.    *
  7.    *                                                                      *
  8.    ***********************************************************************/
  9.  
  10. #include "app.h"
  11.  
  12. /* An input expression to match any RAWMOUSE event with the
  13.  * MBUTTON qualifier bit set
  14.  */
  15. IX middleix = {
  16.    IX_VERSION,             /* required                      */
  17.    IECLASS_RAWMOUSE,
  18.                                                             
  19.                            /* debug: am i listening right?  */
  20.    IECODE_MBUTTON,         /* Code   */
  21.    ~IECODE_UP_PREFIX,      /* CodeMask   */
  22.  
  23.    0,                      /* qualifier I am interested in  */
  24.    0,
  25.    0                       /* synonyms irrelevant           */
  26. };
  27.  
  28. BOOL setupMBA(void);
  29. void middlebaction(struct CxMsg *,CxObj *);
  30.  
  31. BOOL setupMBA()
  32. {
  33.    CxObj   *mfilter;
  34.  
  35.    /* *** middle button trap   ***   */
  36.    mfilter = CxFilter(NULL);
  37.    if (!mfilter)
  38.    {
  39.       return(0);
  40.    }
  41.    SetFilterIX(mfilter, &middleix);
  42.    D( AttachCxObj(mfilter, CxDebug( 0xDEADFACE)) ); /** DEBUG **/
  43.    AttachCxObj(mfilter, CxCustom( middlebaction, 0L));
  44.    if (CxObjError(mfilter))
  45.    {
  46.       D( printf("nocapslock: filter error %lx\n", CxObjError(mfilter) ) );
  47.       DeleteCxObjAll(mfilter);
  48.       return(0);
  49.    }
  50.    AttachCxObj(broker, mfilter);
  51.    D( printf("middle button trap OK\n") );
  52.  
  53.    return(TRUE);
  54. }
  55. void middlebaction(cxm,co)
  56. register struct CxMsg *cxm;
  57. CxObj *co;
  58. {
  59.    register struct InputEvent *ie;
  60.  
  61.    ie = (struct InputEvent *) CxMsgData(cxm);
  62.  
  63. #if 1
  64.    /* i KNOW that all messages getting this far are CXM_IEVENT   */
  65.    /* convert middle button into shift left   */
  66.    ie->ie_Code = (ie->ie_Code & IECODE_UP_PREFIX) | IECODE_LBUTTON;
  67.    ie->ie_Qualifier |= IEQUALIFIER_LSHIFT;
  68.    D( kprintf("middlebaction\n") );
  69. #else
  70.    D( kprintf("leftbaction\n") );
  71.    D( kprintf("code: %x\n", ie->ie_Code ) );
  72. #endif
  73.  
  74. }
  75. VOID handleCustomCXCommand(id)
  76. ULONG id;
  77. {
  78.    switch(id)
  79.    {
  80.       case 0:
  81.       default:
  82.             break;
  83.    }
  84. }
  85.